<template>
  <vo-table ref="voTable" :data="data.tableData" isPage=true>
    <template #leftBar>
      <tiny-form :inline="true" class="demo-form-inline" label-position="left" v-model="searchForm">
        <tiny-form-item label="执行器" label-width="50px">
          <vo-select default select dictCode="jobExcetor" v-model:value="data.searchForm.spaceId" />
        </tiny-form-item>
        <tiny-form-item>
          <tiny-form-item label="状态" label-width="40px">
            <vo-select default dictCode="sysSpaceList" v-model:value="data.searchForm.state" />
          </tiny-form-item>
          <tiny-form-item label="调度时间" label-width="80px">
            <tiny-date-picker v-model="data.searchForm.searchDate" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" range-separator="至"></tiny-date-picker>
          </tiny-form-item>

          <tiny-button type="primary" @click="query">查询</tiny-button>
        </tiny-form-item>
      </tiny-form>
    </template>

    <template v-slot:handleSlot="{row}">
      <tiny-button type="text" size="mini" @click="star(row)">执行日志 </tiny-button>
    </template>
  </vo-table>
</template>

<script setup>
  import {ref, reactive, toRefs, onMounted, getCurrentInstance} from 'vue';
  let {proxy} = getCurrentInstance();
  const data = reactive({searchForm: {}, tableData: {data: [], cols: [], }});

  data.tableData.cols = [
    {type: 'index'},
    {title: '任务名称', key: 'taskName', width: 120, align: 'left', tooltip: true},
    {title: '调度时间', key: 'triggerTime', width: 120, align: 'left', tooltip: true},
    {title: '调度结果', key: 'triggerCode', width: 120, align: 'left', tooltip: true},
    {title: '调度备注', key: 'triggerMsg', align: 'left'},
    {title: '执行时间', key: 'handleTime', align: 'left', tooltip: true},
    {title: '执行结果', key: 'handleCode', align: 'left', tooltip: true},
    {title: '执行备注', key: 'handleMsg', tooltip: true, align: 'center', },
    {title: '操作', slot: 'handleSlot', width: 250},
  ];
  // data.tableData.data = [{id: '1', jobDesc: '测试', jobGroup: '执行器', scheduleType: '', glueType: '', author: 'xx', triggerStatus: '1'}];
  onMounted(()=>{
    query()
  })
  const query = ()=>{
       proxy.$api.taskJob.queryJobLog(data.searchForm).then(res=>{
        data.tableData.data = res;
     });
  }
  const star = row => {
    alert('启动' + row.id);
  };
  // 启动一次
  const exceOneTime = rows => {
    alert(rows.id);
  };
</script>
<style lang="scss" scoped>
  .demo-form-inline {
    .tiny-form-item {
      margin-bottom: 0 !important;
    }
  }
</style>
